package com.example.a2205douyin;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.tencent.rtmp.TXLivePushConfig;
import com.tencent.rtmp.TXLivePusher;
import com.tencent.rtmp.ui.TXCloudVideoView;

public class ZhiboActivity extends AppCompatActivity {
    TXLivePusher mLivePusher;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zhibo);

        TXLivePushConfig mLivePushConfig  = new TXLivePushConfig();
        mLivePusher = new TXLivePusher(this);


// 一般情况下不需要修改 config 的默认配置
        mLivePusher.setConfig(mLivePushConfig);
        //启动本地摄像头预览
        TXCloudVideoView mPusherView = (TXCloudVideoView) findViewById(R.id.pusher_tx_cloud_view);
        mLivePusher.startCameraPreview(mPusherView);


    }

    public void start(View view) {
        String rtmpURL = "rtmp://202023.push.tlivecloud.com/live/wyy?txSecret=af3e56103588f6368aacd36f9a54cfc6&txTime=66B2E258"; //此处填写您的 rtmp 推流地址
        int ret = mLivePusher.startPusher(rtmpURL.trim());
        if (ret == -5) {
            Log.i("sss", "startRTMPPush: license 校验失败");
        }

    }

    public void end(View view) {
        mLivePusher.stopPusher();
        mLivePusher.stopCameraPreview(true); //如果已经启动了摄像头预览，请在结束推流时将其关闭。

    }
}